import { Http } from "@/utils/request";
import { Toast } from "@/utils/toast";
import { delayTask } from "@/utils/timer";

const baseUrl = "/new_guide";

export const new_guide_share_api = (
  data: MiniApp.PagingQuery,
  showError = true
) => {
  return Http.get<MiniApp.PagingData>(
    `/v3${baseUrl}/new_guide_share`,
    data
  ).catch((error: Error) => {
    showError && delayTask(60, () => Toast.show(error.message));
    return Promise.reject(error);
  });
};

export const new_guide_share_info_api = (
  data: { id: string },
  showError = true
) => {
  return Http.get<any>(`/v3${baseUrl}/new_guide_share_info`, data).catch(
    (error: Error) => {
      showError && delayTask(60, () => Toast.show(error.message));
      return Promise.reject(error);
    }
  );
};

export const add_new_guide_share_api = (data: any, showError = true) => {
  return Http.post(`/v3${baseUrl}/add_new_guide_share`, data).catch(
    (error: Error) => {
      showError && delayTask(60, () => Toast.show(error.message));
      return Promise.reject(error);
    }
  );
};
